define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'tide_info/index' + location.search,
                    add_url: 'tide_info/add',
                    edit_url: 'tide_info/edit',
                    del_url: 'tide_info/del',
                    multi_url: 'tide_info/multi',
                    import_url: 'tide_info/import',
                    table: 'tide_info',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {
                            field: 'day_time',
                            title: __('Day_time'),
                            operate:'RANGE',
                            addclass:'datetimerange',
                            autocomplete:false,
                            formatter: Table.api.formatter.datetime,
                            datetimeFormat:'YYYY-MM-DD'
                        },
                        {field: 'time_1', title: __('Time_1'), operate: 'LIKE'},
                        {field: 'height_1', title: __('Height_1')},
                        {field: 'time_2', title: __('Time_2'), operate: 'LIKE'},
                        {field: 'height_2', title: __('Height_2')},
                        {field: 'time_3', title: __('Time_3'), operate: 'LIKE'},
                        {field: 'height_3', title: __('Height_3')},
                        {field: 'time_4', title: __('Time_4'), operate: 'LIKE'},
                        {field: 'height_4', title: __('Height_4')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});